package cn.imu.appdevexperiment2022.start;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import cn.imu.appdevexperiment2022.R;
import cn.imu.appdevexperiment2022.RecyclerView.FourActivity;
import cn.imu.appdevexperiment2022.four.FourActivity1;
import cn.imu.appdevexperiment2022.qqfragment.FragmentMainActivity;
import cn.imu.appdevexperiment2022.three.ThreeActivity;
import cn.imu.appdevexperiment2022.three.ThreeActivity2;
import cn.imu.appdevexperiment2022.two.DialogActivity;
import cn.imu.appdevexperiment2022.two.FirstActivity;
import cn.imu.appdevexperiment2022.two.NormalActivity;
import cn.imu.appdevexperiment2022.two.ThirdActivity;

public class MainActivity extends BaseActivity {

    private static final String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // 系统回收前保存所有数据
        if(savedInstanceState != null){
            String tempData = savedInstanceState.getString("data_key");
            Log.d   (TAG,tempData);
        }

        // 创建跳转到FirstActivity按钮
        // 获取FirstActivity控件id
        Button btn_first = findViewById(R.id.start_FirstActivity);
        btn_first.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, FirstActivity.class);
                startActivity(intent);
            }
        });
        // 创建跳转到Nomal与Dialog的activity
        Button btn_nomal= findViewById(R.id.start_Normal);
        btn_nomal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, NormalActivity.class);
                startActivity(intent);
            }
        });
        Button btn_dialog = findViewById(R.id.start_Dialog);
        btn_dialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, DialogActivity.class);
                startActivity(intent);
            }
        });
        Button btn_third = findViewById(R.id.start_third);
        btn_third.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, ThirdActivity.class);
                startActivity(intent);
            }
        });
        Button btn_three = findViewById(R.id.start_three);
        btn_three.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, ThreeActivity.class);
                startActivity(intent);
            }
        });
        Button btn_three2 = findViewById(R.id.start_three2);
        btn_three2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, ThreeActivity2.class);
                startActivity(intent);
            }
        });
        Button btn_four = findViewById(R.id.start_four);
        btn_four.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, FourActivity.class);
                startActivity(intent);
            }
        });
        Button btn_four1 = findViewById(R.id.four1);
        btn_four1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this,FourActivity1.class);
                startActivity(intent);
            }
        });
        Button btn_fourqq = findViewById(R.id.fourqq);
        btn_fourqq.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, FragmentMainActivity.class);
                startActivity(intent);
            }
        });


    }

    // 观察活动创建
    @Override
    protected void onStart() {
        super.onStart();
        Log.d(TAG,"onStart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.d(TAG,"onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.d(TAG,"onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.d(TAG,"onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.d(TAG,"onDestroy");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.d(TAG,"onRestart");
    }
}
